/**
 * @desc 创建一个普通变量
 * @method set 设置值
 * @method get 获取值
 */

function SimpleValue(value, kind = '') {
    
    /**
     * @desc any value值
     */
    this.value = value;

    /**
     * @desc string kind 变量定义符号 var，const，let
     */
    this.kind = kind;
};

SimpleValue.prototype = {

    ...SimpleValue.prototype,

    set: function(value) {
        // 不可对const类型变量赋值
        if (this.kind === 'const') {
            throw new TypeError('Assignment to constant variable')
        }else {
            this.value = value;
        }
    },

    get: function() {

        return this.value;
    }
};

module.exports = SimpleValue

